package cece.controller;



import cece.entity.Read;
import cece.entity.ReadResp;

import cece.service.ReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ReadController {

    @Autowired
    ReadService readService;

    @GetMapping("/read/findAll/{pageSize}/{pageNum}")
    @ResponseBody
    public ReadResp findAll(@PathVariable("pageSize")Integer pageSize, @PathVariable("pageNum")Integer pageNum){
        return readService.findAll(pageSize,pageNum);
    }

    @GetMapping("/findById/{id}")
    @ResponseBody
    public Read findById(@PathVariable("id") Integer bid){
        return readService.findById(bid);
    }

    @GetMapping("/findByName/{name}")
    @ResponseBody
    public List<Read> findByName(@PathVariable("name")String rname){
        return readService.findByNameLike(rname);
    }
}
